const Banner = require("./modules/bannerModule");

//获取首页信息
const getBanner = async () => {
  return await Banner.findAll();
};

//设置首页信息
const setBanner = async (info) => {
  const { midImg, bigImg, title, description, id } = info;
  await Banner.update(
    {
      midImg,
      bigImg,
      title,
      description,
    },
    {
      where: {
        id,
      },
    }
  );
  return await Banner.findByPk(id);
};

//添加首页信息
const addBanner = async (info) => {
  await Banner.create(info);
};
module.exports = {
  getBanner,
  setBanner,
  addBanner,
};
